Option Explicit On Option Strict On Public Class Form1 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents Label1 As System.Windows.Forms.Label Friend WithEvents GroupBox2 As System.Windows.Forms.GroupBox Friend WithEvents LstStudents As System.Windows.Forms.ListBox Friend WithEvents BtnDesc As System.Windows.Forms.Button Friend WithEvents BtnAsc As System.Windows.Forms.Button Friend WithEvents BtnQuit As System.Windows.Forms.Button Private Sub InitializeComponent() Me.Label1 = New System.Windows.Forms.Label Me.GroupBox2 = New System.Windows.Forms.GroupBox Me.LstStudents = New System.Windows.Forms.ListBox Me.BtnDesc = New System.Windows.Forms.Button Me.BtnAsc = New System.Windows.Forms.Button Me.BtnQuit = New System.Windows.Forms.Button Me.GroupBox2.SuspendLayout() Me.SuspendLayout() ' 'Label1 ' Me.Label1.AutoSize = True Me.Label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 18.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label1.Location = New System.Drawing.Point(136, 40) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(392, 37) Me.Label1.TabIndex = 0 Me.Label1.Text = "Dr Test's Midterm Analysis" ' 'GroupBox2 ' Me.GroupBox2.Controls.Add(Me.LstStudents) Me.GroupBox2.Location = New System.Drawing.Point(32, 168) Me.GroupBox2.Name = "GroupBox2" Me.GroupBox2.Size = New System.Drawing.Size(352, 248) Me.GroupBox2.TabIndex = 4 Me.GroupBox2.TabStop = False Me.GroupBox2.Text = "Student Results (sorted)" ' 'LstStudents ' Me.LstStudents.ItemHeight = 16 Me.LstStudents.Location = New System.Drawing.Point(24, 32) Me.LstStudents.Name = "LstStudents" Me.LstStudents.Size = New System.Drawing.Size(312, 196) Me.LstStudents.TabIndex = 0 ' 'BtnDesc ' Me.BtnDesc.Location = New System.Drawing.Point(32, 104) Me.BtnDesc.Name = "BtnDesc" Me.BtnDesc.Size = New System.Drawing.Size(112, 40) Me.BtnDesc.TabIndex = 5 Me.BtnDesc.Text = "High to Low" ' 'BtnAsc ' Me.BtnAsc.Location = New System.Drawing.Point(168, 104) Me.BtnAsc.Name = "BtnAsc" Me.BtnAsc.Size = New System.Drawing.Size(112, 40) Me.BtnAsc.TabIndex = 6 Me.BtnAsc.Text = "Low to High" ' 'BtnQuit ' Me.BtnQuit.Location = New System.Drawing.Point(304, 104) Me.BtnQuit.Name = "BtnQuit" Me.BtnQuit.Size = New System.Drawing.Size(112, 40) Me.BtnQuit.TabIndex = 7 Me.BtnQuit.Text = "Quit" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(6, 15) Me.ClientSize = New System.Drawing.Size(760, 568) Me.Controls.Add(Me.BtnQuit) Me.Controls.Add(Me.BtnAsc) Me.Controls.Add(Me.BtnDesc) Me.Controls.Add(Me.GroupBox2) Me.Controls.Add(Me.Label1) Me.Name = "Form1" Me.Text = "Form1" Me.GroupBox2.ResumeLayout(False) Me.ResumeLayout(False) End Sub #End Region Dim scores(100) As Double Dim numStd As Integer Private Sub display(ByVal arr() As Double, ByVal numEl As Integer) Dim cnt As Integer For cnt = 0 To (numEl - 1) LstStudents.Items.Add(arr(cnt)) Next End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim inpf As IO.StreamReader Dim std As Integer = 0 Dim currLine As String Dim max As Double = 0 Dim min As Double = 100 Dim sum As Double = 0 Dim middleMean As Double Dim curve As Double Dim cnt As Integer Dim outString As String If IO.File.Exists("scores.txt") Then ' read student scores out of file into array inpf = IO.File.OpenText("scores.txt") Do Until inpf.Peek = -1 currLine = inpf.ReadLine() ' if appropriat einput add to the array and prepare to go to next element If IsNumeric(currLine) Then scores(std) = Convert.ToDouble(currLine) ' prepare for next student std = std + 1 End If Loop numStd = std End If End Sub Private Sub BtnDesc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnDesc.Click LstStudents.Items.Clear() Array.Sort(scores) Array.Reverse(scores) display(scores, numStd) End Sub Private Sub BtnAsc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnAsc.Click LstStudents.Items.Clear() Array.Sort(scores) Dim cnt As Integer For cnt = (100 - (numStd - 1)) To 100 LstStudents.Items.Add(scores(cnt)) Next cnt End Sub Private Sub BtnQuit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnQuit.Click Me.Close() End Sub End Class